package com.mxprojects.gui
{
	import com.mxprojects.constructors.Divider;
	import com.mxprojects.constructors.DrawBorder;
	import com.mxprojects.io.Config;
	import com.mxprojects.language.Language;
	import com.mxprojects.language.Word;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class CategoryHeader extends BaseForumElement
	{
		private const DIVIDER_COUNT:int = 3;
		
		public var forum:TextField;
		public var threads:TextField;
		public var posts:TextField;
		public var lastPost:TextField;
				
		public function CategoryHeader(){
			//do whatever CSS tells us to do
			forum.styleSheet = Styles.css;
			threads.styleSheet = Styles.css;
			posts.styleSheet = Styles.css;
			lastPost.styleSheet = Styles.css;
			
			//when this is put on the stage load the language
			forum.htmlText = "<span class=\"categoryHeaderForum\">" + Language.main(Word.FORUMS) + "</span>";
			threads.htmlText = "<span class=\"categoryHeaderThreads\">" + Language.main(Word.THREADS) + "</span>";
			posts.htmlText = "<span class=\"categoryHeaderPosts\">" + Language.main(Word.POSTS) + "</span>";
			lastPost.htmlText = "<span class=\"categoryHeaderLastPost\">" + Language.main(Word.LAST_POST) + "</span>";
			
			//handle the basics
			super.init(".categoryHeaderBackground", DIVIDER_COUNT);
		}
		
		override public function resize():void {
			placeStuff();
			
			super.resize();
		}
		
		private function placeStuff():void {
			//place titles in proper spot
			lastPost.x = Math.round(MXP3.wStage - lastPost.width);
			posts.x = Math.round(lastPost.x - posts.width - Config.TEXT_PADDING);
			threads.x = Math.round(posts.x - threads.width - Config.TEXT_PADDING);
						
			//move dividers
			getDivider(0).x = Math.round(threads.x - (Config.TEXT_PADDING/2));
			getDivider(1).x = Math.round(posts.x - (Config.TEXT_PADDING/2));
			getDivider(2).x = Math.round(lastPost.x - (Config.TEXT_PADDING/2));			
		}
	}
}